export const state = () => {
    return {
        questions: []
    }
}
export const mutations = {
    SET_QUESTIONS(state, data) {
        state.questions = data
    }

}
export const actions = {
    // 渲染页面
    async getQuestionData({ commit }, $axios) {
        let { data } = await $axios.get('http://localhost:2345/questions/examList')
        commit("SET_QUESTIONS", data.data)
    },
    // 新增
    async addClassifyData({ dispatch }, { $axios, form }) {
        console.log(form)
        let { data } = await $axios.post("http://localhost:2345/questions/saveExam",form)
        console.log(data);
        dispatch("getQuestionData", $axios)
    },
    // 删除
    async delClassifyData({ dispatch }, { $axios, id }) {
        let r = await $axios.get("http://localhost:2345/questions/deleteExam?id=" + id);
        dispatch("getQuestionData", $axios)
    },
    // 修改
    async putClassify({ dispatch, commit }, { $axios, data }) {
        await $axios.post("http://localhost:2345/questions/updateExam", data);
        dispatch("getQuestionData", $axios)
    }
}
export const getters = {

}